fix: implement missing utilities and fix edge-case bugs#236
Open
stooit wants to merge 1 commit into
Open
Conversation
…ests - string-utils: fix wordCount on consecutive spaces; implement truncate - task-manager: implement remove, update, and sortBy (priority/createdAt) - validator: accept long TLDs in isEmail; fix isUrl port handling - calculator: throw on division by zero - date-utils: fix formatRelative tier-boundary rounding (off-by-one) All 60 tests pass. No test files or dependencies modified.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes all 16 previously-failing tests pass (now 60 pass / 0 fail) without modifying any test files or adding dependencies. Only source files under
src/were changed.Changes by file
src/string-utils.ts—wordCountnow trims and splits on\s+so consecutive spaces don't produce empty tokens; implementedtruncate(returns unchanged within limit, breaks at word boundary within themaxLength - ellipsisbudget, ellipsis counts toward the limit).src/task-manager.ts— implementedremove(returnsfalsefor unknown id),update(title/priority, returnsfalsefor unknown id), andsortByforpriority(high → medium → low) andcreatedAt(oldest first).src/validator.ts—isEmailaccepts long TLDs (e.g..museum);isUrlcorrectly handles URLs with a port.src/calculator.ts—dividethrows on division by zero.src/date-utils.ts— fixedformatRelativeoff-by-one: tier selection now branches on the rounded magnitude so boundary cases (23.5h, 59.5min) roll up correctly instead of rendering "24 hours"/"60 minutes".Verification
bun test: 60 pass, 0 fail (70 assertions).test/were modified; no dependencies added.formatRelativefix — that was corrected before this PR.Assumptions
formatRelativetier rounding was corrected to be internally consistent, a small behavioural improvement beyond the minimum required by the failing test.